-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new (list) Statistics node (WIP) #2334
Conversation
Any suggestions, comments ? Questions:
|
Originally I was trying to see if i can implement the node using scipy since it has all these stats and many more, but it seems that blender doesn’t include scipy by default. |
nodes/list_main/statistics.py
Outdated
from math import sqrt, floor | ||
|
||
functions = { | ||
"SUM": (10, lambda l: get_sum(l)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-"SUM": (10, lambda l: get_sum(l)),
+"SUM": (10, get_sum),
why use a lambda to directly call a function?
i wish scipy was included in the blender distro too :) neat node btw. |
also be aware of the list modifier node ( https://github.com/nortikin/sverchok/blob/master/nodes/list_mutators/modifier.py ) , the nebulous name was an attempt to allow adding functions to the node that weren't easily classifiable. regarding your question about dealing with input like
have two functions then, avg_float, avg_int
The user should be aware that their input will result in different output depending on the mode, and pick accordingly adding a |
nodes/list_main/statistics.py
Outdated
|
||
input_p = list(map(lambda x: max(0, min(1,x)), input_p)) | ||
|
||
function = self.get_statistics_function() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
soft advice here .. you are reusing function
variable name, while the node has a member variable called function
already. maybe don't do that.
nodes/list_main/statistics.py
Outdated
updateNode(self, context) | ||
|
||
function = EnumProperty( | ||
name="Function", items=function_items, update=update_function) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when the Property attribute items
is passed a function, the function is evaluated each time the enum is told to "drop down" in the UI. the passing of a function is useful for dynamic situations where the content of the dropdown may be updated/changed at runtime.
I recommend using something more hardcoded here, evaluated only once. Unless you plan to add more statistical modes which depend on some 'switch' to populate the return values differently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.. I wanted to have one dictionary for both the function getter and the function drop down items. I wonder if such optimization is worth it since the drop down operations is occasional and not in the processing loop to slow down the node. I can implement it to still use one dictionary and precompute this function list so it doesn’t get regenerated every time you drop down. I am trying to avoid having to define two lists one that maps the function name to function, and one that maps function name to a function list item.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well.. i forgot that this also updates whenever the viewport updates. like whenever you move your mouse. So..
def function_items(self, context):
print('i happen more often than you think')
return [(k, k.title(), "", "", s[0]) for k, s in sorted(functions.items(), key=lambda k: k[1][0])]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it to use a precomputed list
4c71559
to
684d9c8
Compare
02933d9
to
2f08a11
Compare
Should this node be called “Statistics" or “List Statistics” ? |
the addition of |
I have a question about nesting.. For instance, when computing a statistical quantity like average, sum, maximum etc that result in a single value the output is something like [[v]] .. and for a vectorized input (e.g. multiple lists or list + multiple percentages in case of the percentile) the output is like [[v1, v2, .. vn]]. However, for a histogram the output is a list of values (the bin values) not just a single value, so for a simple input the output is [[[b1, b2, .. bn]]]. For a vectorized input the output would be [[ [a1, a2,..., an], [b1, b2,..., bn], ..., [c1, c2,..cn] ]] (note the 3 nested level). I’m not sure what’s the use of the extra nested level in this case. Maybe I don’t fully understand the philosophy behind the output nested levels. On one hand I’m thinking maybe I should keep the 3 level nesting for histogram since an output value for this statistical quantity is a list, not a number.. but on the other I feel that this extra level is just not useful. Any thoughts on this matter? |
the downside to having a node output wildly different data depending on mode or input
the point to having outer nesting level is that no matter how complicated the data is, it will always inform the reading node how many items are contained in its list by doing we aren't in the business of forcing you to output arbitrary nestedness, in complex data it may very well be a nuisance. |
…ing the following: Sum Sum Of Squares Product Average Geometric Mean Harmonic Mean Standard Deviation Root Mean Square Skewness Kurtosis Minimum Maximum Median Percentile Histogram
eb454b0
to
421d246
Compare
Add node to compute various statistical quantities, currently supporting the following:
note: This may eventually replace the List Math & List Sum node.